package com.pgy.backend.vo;


import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ResultData<T> {
    private int code;
    private String message;
    private T data;
    //操作成功，且带参数返回
    public static <T> ResultData<T> success(String message, T data) {
        return new ResultData<>(ReturnCode.CODE_200.getCode(), message, data);
    }
    public static <T> ResultData<T> success(T data){return new ResultData<>(ReturnCode.CODE_200.getCode(),ReturnCode.CODE_200.getMessage(), data);}


    //数据库里没有找到对应数据
    public static <T> ResultData<T> NotFind(int code, String message) {
        return new ResultData<>(code, message, null);
    }

    //数据库新增失败
    public static <T> ResultData<T> NotInsert(int code, String message) {
        return new ResultData<>(code, message, null);
    }

    //数据库删除失败
    public static <T> ResultData<T> error(int code, String message) {
        return new ResultData<>(code, message, null);
    }




}
